<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title></title>
    <link rel="stylesheet" href="<?php echo STATICURL; ?>css/bootstrap.min.css" />
    <script src="<?=STATICURL; ?>js/jquery.min.js"></script>
</head>

<body style="background: #eeeeee;">
    <div class="widget-content" >
        <table class="table" style="margin-top: 20px;">
            <tbody>
            <tr>
                <td>考试名称</td>
                <td><input id="examinationName" style="width: 320px;" type="text" value="<?=$examinationInfo['examinationTitle']?>"  placeholder="请输入考试名称"/><input type="hidden" name="examID" id="examID" value="<?=$examinationInfo['examinationID']?>"></td>
            </tr>
            <tr>
                <td>考试时间</td>
              
                <td><input type="text" class = "datepicker" placeholder="请输入考试时间"  style="width: 320px;" id="dateTime" readonly="readonly" onClick="WdatePicker()" value="" ></td>
            </tr>
            <tr>
                <td>单选题数目</td>
                <td><input id="radioNum"  style="width: 220px;" type="text" value=""  placeholder="请输入数字"/></td>
            </tr>
            <tr>
                <td>多选题数目</td>
                <td><input id="checkNum"  style="width: 220px;" type="text" value=""  placeholder="请输入数字"/></td>
            </tr>
            <tr>
                <td>判断题数目</td>
                <td><input id="ifNum"  style="width: 220px;" type="text" value=""  placeholder="请输入数字"/></td>
            </tr>
            <tr>
                <td>填空题数目</td>
                <td><input id="inputNum"  style="width: 220px;" type="text" value=""  placeholder="请输入数字"/></td>
            </tr>
            <tr>
                <td>简答题数目</td>
                <td><input id="textareaNum"  style="width: 220px;" type="text" value=""  placeholder="请输入数字"/></td>
            </tr>
            <tr>
                <td>考试部门</td>
                <td>
                    <div class="control-group">
                        <div class="controls">
                            <select id="deptID">
                                    <?php if(!empty($examinationInfo)){?>
                                    <option value = "<?=$examinationInfo['examinationDept']?>"><?=$examinationInfo['name']?></option>
                                    <?php }else{?>
                                        <option value = "0">--请选择部门--</option>
                                        <?php foreach($deptList as $key=>$value):?>
                                            <option value = "<?=$value['id']?>"><?=$value['name']?></option>
                                        <?php endforeach;?>
                                    <?php }?>
                            </select>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>考试人员</td>
                <td>
                    <div class="control-group">
                        <div class="controls">
                            <select id="UID">
                                <option value = "0"><?=$userMsg?></option>
                            </select>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="border-right: 0;">&nbsp;</td>
                <td style="border-left: 0;"><a style="float:left" type="submit" class="js_btn btn btn-success" href="javascript:void(0)" id="edit_manager">创建考试</a></td>
            </tr>
            </tbody>
        </table>
    </div>
</body>
<script src="<?=STATICURL; ?>js/wdatepicker/WdatePicker.js"></script>
<script type="text/javascript">
</script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#edit_manager").click(function(){
            var examinationName = $("#examinationName").val();
            var dateTime = $("#dateTime").val();
            var deptID = $("#deptID").val();
            var examID = $("#examID").val();
            var radioNum = $("#radioNum").val();
            var checkNum = $("#checkNum").val();
            var ifNum = $("#ifNum").val();
            var inputNum = $("#inputNum").val();
            var textareaNum = $("#textareaNum").val();
            if(examinationName == '')
            {
                alert("考试名称不能为空");
                return false;
            }
            if(dateTime== '')
            {
                alert("考试时间不能为空");
                return false;
            }
            if(deptID == ""){
                alert("请选择考试部门");
                return false;
            }
            if(radioNum >15 || isNaN(radioNum)){
                alert("单选题最多15道");
                return false;
            }
            if(checkNum >10 || isNaN(checkNum)){
                alert("多选题最多10道");
                return false;
            }
            if(ifNum >10 || isNaN(ifNum)){
                alert("判断题最多10道");
                return false;
            }
            if(inputNum >10 || isNaN(inputNum)){
                alert("填空题最多10道");
                return false;
            }
            if(textareaNum >3 || isNaN(textareaNum)){
                alert("简答题最多3道");
                return false;
            }

            $.post("/luckydog/examination/edit_exam",{"examinationName":examinationName,"dateTime":dateTime,'deptID':deptID,'examID':examID,"radioNum":radioNum,'checkNum':checkNum,'ifNum':ifNum,'inputNum':inputNum,'textareaNum':textareaNum},function(res){
                if (res.status.code == 200) {
                    alert('考试创建成功');
                     window.parent.location.reload();
                }
            },"json");
        });
    });
</script>